OBJS = objs
MAINLIB=/home/pi/csr-repository/lib/
CFLAGS_OPENCV = -I/usr/local/include/opencv -I/home/pi/csr-repository/include/ -I/opt/vc/include/
LDFLAGS2_OPENCV = -lopencv_highgui -lopencv_core -lopencv_legacy -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_imgproc

USERLAND_ROOT = /opt/vc/userland
CFLAGS_PI = \
	-I$(USERLAND_ROOT)/host_applications/linux/libs/bcm_host/include \
	-I$(USERLAND_ROOT)/host_applications/linux/apps/raspicam \
	-I$(USERLAND_ROOT) \
	-I$(USERLAND_ROOT)/interface/vcos/pthreads \
	-I$(USERLAND_ROOT)/interface/vmcs_host/linux \
	-I$(USERLAND_ROOT)/interface/mmal 

LDFLAGS_PI = -L$(USERLAND_ROOT)/build/lib -lmmal_core -lmmal -l mmal_util -lvcos -lbcm_host -lmmal_vc_client -lGLESv2 -lEGL -lcolor_thresholding -L/usr/local/lib/ -L$(HOME)/csr-repository/lib/

BUILD_TYPE=debug
#BUILD_TYPE=release

CFLAGS_COMMON = $(CFLAGS_OPENCV) $(CFLAGS_PI) -MD

ifeq ($(BUILD_TYPE), debug)
	CFLAGS = $(CFLAGS_COMMON) -g
endif
ifeq ($(BUILD_TYPE), release)
	CFLAGS = $(CFLAGS_COMMON) -O3
endif

LDFLAGS = 
LDFLAGS2 = $(LDFLAGS2_OPENCV) $(LDFLAGS_PI) -lX11 -lXext -lrt -lstdc++ 

FINDER_OBJS = \
	graphics.o \
    robotfinder.o \
    $(MAINLIB)libcamera_gpu.so

OBJS = test.o \
       $(FINDER_OBJS) 


TARGETS = test $(MAINLIB)librobotfinder.so



all: $(TARGETS)


%.o: %.cpp
	gcc -c $(CFLAGS) $< -o $@

$(MAINLIB)librobotfinder.so: $(FINDER_OBJS)
	gcc -shared -o $@ $(LDFLAGS2) $+ 
test: test.o $(MAINLIB)libcamera_gpu.so $(MAINLIB)librobotfinder.so
	gcc $(LDFLAGS) test.o $(LDFLAGS2) -L. -lrobotfinder -lcamera_gpu -o $@

clean:
	rm -f *.o $(TARGETS)

